<?php
/**
 * 教室信息类
 */
namespace app\admin\controller;

use think\App;
use think\facade\View;

class Program extends Strategy
{

    public function __construct(App $app)
    {
        parent::__construct($app);
    }

    public function index()
    {
        parent::index();
        return view('strategy/index');
    }

    public function add(){
        $showData = parent::add();
        if($this->id){
            $showData['id'] = $this->id;
            $showData['start'] = 100;
            $showData['detail'] = $this->localModel->findDetaiById('*', $this->id);
            $showData['equipment'] = $this->equipment->findAllInfo('id, title', [['crid', '=', session('adminUserInfo.cid')], ['type', '=', $showData['detail']['screen_type']]]);
            $showData['detailList'] = $this->localModel->getTacticsDetailById($this->id);//print_r($showData['detailList']);
            if(session('adminUserInfo.cid'))  $showData['equipment_relation'] = $this->localModel->getTacticsEquipmentRelation($this->id, $showData['detail']['screen_type']);
            View::assign($showData);
            return view('strategy/edit');
        }else{
            if(session('adminUserInfo.cid')){
                $showData['crInfo'] = $this->croommodel->findDetaiInfoById("type, level", session('adminUserInfo.cid'));
            }
            View::assign($showData);
            return view('strategy/add');
        }
    }

    public function save(){
        $this->validateType = 'program';
        return parent::save();
    }

}
